package me.xplabs.model.skill 
{
	import flash.utils.Dictionary;
	import flash.utils.getTimer;
	import me.xplabs.interfaces.IHeartbeat;
	import me.xplabs.model.combatunit.BaseBuild;
	import me.xplabs.model.GameDataSingleton;
	import me.xplabs.utils.MacroObjPool;
	/**
	 * 技能管理器
	 * ...
	 * @author xiaohan
	 */
	public class SkillManager
	{
		/** 技能列表*/
		public var skills:Vector.<Skill>;
		/** 使用技能时回调*/
		public var useSkillCall:Function;
		public function SkillManager() 
		{
			skills = new Vector.<Skill>();
		}
		/**
		 * 心跳函数，刷新技能的cd时间
		 * @param	gap
		 */
		public function heartbeat(gap:int):void 
		{
			var len:int = skills.length;
			for (var i:int = 0; i < len; i++) 
			{
				skills[i].updateCdGap();
				if (skills[i].isUse)
				{
					useSkill(skills[i]);
				}
			}
		}
		/**
		 * 添加一个技能
		 * @param	p_skill
		 */
		public function addSkill(p_skill:Skill):void 
		{
			skills.push(p_skill);
		}
		/**
		 * 使用技能
		 * @param	skill
		 */
		private function useSkill(skill:Skill):void
		{
			if (useSkillCall != null) 
			{
				if (useSkillCall(skill))
				{
					skill.useSkill();
				}
			}
			//trace("使用技能");
		}
		public function dispose():void
		{
			
		}
		
		public function clearSkills():void 
		{
			skills.length = 0;
		}
	}
}